/**
 * @Author: 陈瑞鹏
 * @Date:   2023-01-11 15:35:28
 * @Last Modified by:   陈瑞鹏
 * @Last Modified time: 2023-01-11 17:20:10
 */
import signCtr from "../ctrs/sign/signCtr";
import BaseGameLayer from "../libs/core/BaseGameLayer";
import { PureMVCEvents } from "../libs/core/PureMVCEvents";
import { drawScroll2 } from "../libs/core/utils";
import { INotification } from "../libs/pureMvc/Interfaces";

const { ccclass, property } = cc._decorator
@ccclass
export default class signLayer extends BaseGameLayer {

  @property({ type: cc.Node, tooltip: "内容节点" })
  contentNode: cc.Node = null;

  @property({ type: cc.Prefab, tooltip: "签到预制体" })
  signPre: cc.Prefab = null;

  onEnable(): void {
    super.onEnable();
    this.drawUI();
  }

  public listNotificationInterests(): string[] {
    return [PureMVCEvents.ON_SIGN_UDPATE]
  }
  public handleNotification(notification: INotification): void {
    let name = notification.getName();
    switch (name) {
      case PureMVCEvents.ON_SIGN_UDPATE:
        this.drawUI();
        break;
    }
  }

  drawUI() {
    let list = signCtr.ins.signDic.getValueList();
    drawScroll2(this.contentNode, list, this.signPre, "signCom", 1, 0, 10);
  }
}